<?php

if($frmtGroup){
?>
<div id="" >
  <table id="debtors-table-data" class="data_table" width="100%" border="0" align="center">
      <thead style="background-color: #1C1C1C; font-size: 12px; font-family: Verdana,Arial,sans-serif; color: white;">
      <th width="13%" align="left">Registration Id</th>
      <th width="20%" align="left"> Property Name</th>
      <th width="20%" align="left">Owner</th>
      <th width="10%" align="left">Telephone</th>
      <th width="7%" align="left">Bill Year</th>
      <th width="10%" align="left"><?php echo 'Total Bill ' . CURRENCY; ?></th>
      <th width="10%" align="left"><?php echo 'Total Paid ' . CURRENCY; ?></th>
      <th width="10%" align="left"><?php echo 'Owing ' . CURRENCY; ?></th>
      </thead>
     <tbody>
      <?php
          $bill_tl = 0.00;
          $paid_tl = 0.00;
          $owe_tl = 0.00;
            foreach($frmtGroup as $prp){
                $bill = 0.00;
                if ($prp['Bill']) {
                    $bill = floatval($prp['Bill']['ttl_bill']);
                    $bill_tl = $bill_tl + $bill;
                }
                $paid = 0.00;
                if ($prp['Bill']) {
                    $paid = floatval($prp['Bill']['ttl_payment']);
                    $paid_tl = $paid_tl + $paid;
                }
                $owe = 0.00;
                if ($prp['Bill']) {
                    $owe = floatval($prp['Bill']['debit']);
                    $owe_tl = $owe_tl + $owe;
                }
             ?>
                <tr>
                    <td width="13%" align="left">
                        <?php echo $prp['Property']['property_reg_no']; ?>
                    </td>
                    <td width="20%" align="left">
                        <?php echo $prp['Property']['name']; ?>
                    </td>
                    <td width="20%" align="left">
                        <?php echo $prp['Property']['owners_name']; ?>
                    </td>
                    <td width="10%" align="left">
                        <?php echo $prp['Property']['telephone']; ?>
                    </td>
                    <td width="7%" align="left">
                        <?php echo isset($prp['Bill']['year']) ? $prp['Bill']['year'] : ''; ?>
                    </td>
                    <td width="10%" align="left">
                        <?php
                        echo $bill;
                        ?>
                    </td>
                    <td width="10%" align="left">
                        <?php
                        echo $paid;
                        ?>
                    </td>
                    <td width="10%" align="left">
                        <?php
                        echo $owe;
                        ?>
                    </td>
                </tr>
             <?php 
           }
      ?>
    </tbody> 
  </table>
</div>
    <table width="100%">
        <thead style="font-size: 12px; font-family: Verdana,Arial,sans-serif;">
        <th width="13%" align="left"></th>
        <th width="20%" align="left"></th>
        <th width="20%" align="left"></th>
        <th width="10%" align="left"></th>
        <th width="10%" align="left">Total</th>
        <th width="10%" align="left"><?php echo CURRENCY.' '.$bill_tl; ?></th>
        <th width="10%" align="left"><?php echo CURRENCY.' '.$paid_tl; ?></th>
        <th width="10%" align="left"><?php echo CURRENCY.' '.$owe_tl; ?></th>
        </thead>
    </table>
<?php
}
else{
    echo "No Report At the Moment.";
}

?>